import React from 'react';
import styled from 'styled-components';

interface HoverInfoBoxProps {
  x: number;
  y: number;
  title: string;
  items: Array<{
    label: string;
    value: string | number;
  }>;
}

const Container = styled.div<{ x: number; y: number }>`
  position: absolute;
  left: ${props => props.x}px;
  top: ${props => props.y}px;
  transform: translate(-50%, -100%);
  background: linear-gradient(
    135deg,
    rgba(0, 20, 50, 0.95) 0%,
    rgba(0, 40, 80, 0.95) 100%
  );
  border: 1px solid rgba(0, 150, 255, 0.5);
  padding: 10px;
  border-radius: 4px;
  min-width: 200px;
  pointer-events: none;
  z-index: 1000;

  &::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 150, 255, 0.5);
  }

  &::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 40, 80, 0.95);
  }
`;

const Title = styled.div`
  color: rgba(0, 150, 255, 0.8);
  font-size: 14px;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(0, 150, 255, 0.3);
`;

const InfoItem = styled.div`
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0;
  font-size: 12px;
  
  .label {
    color: rgba(255, 255, 255, 0.7);
  }
  
  .value {
    color: #fff;
  }
`;

const HoverInfoBox: React.FC<HoverInfoBoxProps> = ({ x, y, title, items }) => {
  return (
    <Container x={x} y={y}>
      <Title>{title}</Title>
      {items.map((item, index) => (
        <InfoItem key={index}>
          <span className="label">{item.label}</span>
          <span className="value">{item.value}</span>
        </InfoItem>
      ))}
    </Container>
  );
};

export default HoverInfoBox; 